from datetime import datetime
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from applications.extensions import db

def get_current_time():
    create_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    return datetime.strptime(create_at, "%Y-%m-%d %H:%M:%S")

class Device_buy(db.Model, UserMixin):
    __tablename__ = 'device_buy'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='设备ID')
    deviceName = db.Column(db.String(20), comment='设备名称')
    typeNum = db.Column(db.String(60), comment='设备型号')
    producer = db.Column(db.String(50), comment='制造商')
    warranty = db.Column(db.String(50), comment='保修期')
    min_money = db.Column(db.Float, comment='最低购买金额')
    max_money = db.Column(db.Float, comment='最高购买金额')
    create_at = db.Column(db.DateTime, default=get_current_time(), comment='发起日期')
    detail = db.Column(db.String(50), comment='情况说明')
